package com.imooc.framework.innerclass;

public class StaticInnerClass {

    private static String outName = "张三";
    private Integer outAge = 18;

    public static void outerStaticMethod(){
        System.out.println("outerStaticMethod" + outName);
    }

    public void outerNoStaticMethod(){
        System.out.println("outerNoStaticMethod" + outName + outAge);
    }

    static class StaticInner{
         static String innerName = "张三";
         Integer innerAge = 18;

        public StaticInner(Integer innerAge) {
            this.innerAge = innerAge;
        }

        {
            System.out.println("测试静态内部类非静态代码块");
        }

        static {
            System.out.println("测试静态内部类静态代码块");
        }

        public static void staticMethod(){
            System.out.println("staticMethod" + innerName);
            StaticInner staticInner = new StaticInner(30);
            System.out.println("staticMethod" + staticInner.innerAge);

            System.out.println("staticMethod" + outName);
            StaticInnerClass staticInnerClass = new StaticInnerClass();
            System.out.println("staticMethod" + staticInnerClass.outAge);

            outerStaticMethod();
            staticInnerClass.outerNoStaticMethod();
        }

        public void noStaticMethod(){
            System.out.println("noStaticMethod" + innerName);
            System.out.println("noStaticMethod" + innerAge);

            System.out.println("noStaticMethod" + StaticInnerClass.outName);
            StaticInnerClass staticInnerClass = new StaticInnerClass();
            System.out.println("noStaticMethod" + staticInnerClass.outAge);

            outerStaticMethod();
            staticInnerClass.outerNoStaticMethod();
        }
    }

    public static void main(String[] args) throws InterruptedException {
        StaticInnerClass.StaticInner staticInner = new StaticInnerClass.StaticInner(20);
        Integer innerAge = staticInner.innerAge;
        staticInner.noStaticMethod();

        String innerName = StaticInner.innerName;
        StaticInner.staticMethod();
    }
}
